package com.example.demo.server.model;

import com.example.demo.server.common.APPVariable;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Objects;


public class UserInfo {
    private int id;
    private String username;
    private String name;
    private String password;
    private Timestamp createtime;
    private Timestamp updatetime;
    private int state;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCreatetime() {
        return new SimpleDateFormat(APPVariable.DATA_FORMAT).format(createtime);
    }

    public void setCreatetime(Timestamp createtime) {
        this.createtime = createtime;
    }

    public String getUpdatetime() {
        return new SimpleDateFormat(APPVariable.DATA_FORMAT).format(updatetime);
    }

    public void setUpdatetime(Timestamp updatetime) {
        this.updatetime = updatetime;
    }


    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserInfo userInfo = (UserInfo) o;
        return id == userInfo.id && state == userInfo.state && Objects.equals(username, userInfo.username) && Objects.equals(name, userInfo.name) && Objects.equals(password, userInfo.password) && Objects.equals(createtime, userInfo.createtime) && Objects.equals(updatetime, userInfo.updatetime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, username, name, password, createtime, updatetime, state);
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", createtime=" + createtime +
                ", updatetime=" + updatetime +
                ", state=" + state +
                '}';
    }
}
